FROM python:3.9-slim

WORKDIR /app

# 安装系统依赖
RUN apt-get update && \
    apt-get install -y --no-install-recommends gcc g++ && \
    rm -rf /var/lib/apt/lists/*

# 安装 Python 依赖
COPY app/code/requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt

# 复制全部代码、数据、模型
COPY app/ /app/

# 赋予脚本可执行权限
RUN ls -l /app/ && \
    [ -f /app/init.sh  ] && chmod +x /app/init.sh  || echo "init.sh  missing"  && \
    [ -f /app/train.sh ] && chmod +x /app/train.sh || echo "train.sh missing" && \
    [ -f /app/test.sh  ] && chmod +x /app/test.sh  || echo "test.sh  missing"

# 默认入口
ENTRYPOINT []
CMD ["./test.sh"]